package com.example.gulimall.third.controller;

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>@description: 短信发送  </p>
 * <p>@author: JGD </p>
 * <p>@create: 2020/4/20 20:26 </p>
 * <p>@version : 2.0.0
 **/
@RestController
@RequestMapping("sms")
public class SmsApi {
    public static void main(String[] args) {
        String accessKeyId = "LTAI4GDCec7b1ShL4mgUqR19";
        String accessKeySecret = "XNKCuM5gAm0PI8W0M4NWyHruxWSVks";
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.POST);
        request.setSysDomain("dysmsapi.aliyuncs.com");
        request.setSysVersion("2017-05-25");
        request.setSysAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", "13835380408");
        request.putQueryParameter("SignName", "小群群商城专卖");
        request.putQueryParameter("TemplateCode", "SMS_188555609");
        request.putQueryParameter("TemplateParam", "{\"code\":\"8888\"}");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }



}
